Completed
Push — master ( 0fd50e...a1b69c )
by
unknown
06:56
created

post-sql-request.js ➔ ... ➔ ???   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 1
c 2
b 0
f 0
nc 1
dl 0
loc 5
rs 9.4285
nop 0
1
import {
2
  cmsData
3
  ,abeExtend
4
} from '../../cli'
5
6
var route = function(req, res, next){
7
  abeExtend.hooks.instance.trigger('beforeRoute', req, res, next)
8
  if(typeof res._header !== 'undefined' && res._header !== null) return
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
9
10
  var sourceString = req.body.sourceString
11
  var prefillQuantity = req.body.prefillQuantity
12
  var folder = req.body.folder
13
  var key = req.body.key
14
  var jsonPage = (req.body.json) ? JSON.parse(JSON.stringify(req.body.json)) : {}
15
16
  jsonPage[key] = null
17
18
  var request = `{{abe type="data" key="${key}" source="${sourceString}" prefill="true" prefill-quantity='${prefillQuantity}' editable="true"}}`
19
  var obj = cmsData.attributes.getAll(request, jsonPage)
20
  
21
  cmsData.source.requestList(obj, folder, request, jsonPage)
22
    .then(() => {
23
24
      res.set('Content-Type', 'application/json')
25
      res.send(JSON.stringify(jsonPage[key]))
26
    })
27
}
28
29
export default route